<%@page import="com.crm.entity.Sources,java.util.*,com.crm.entity.Business" %>
<%@page import="com.crm.entity.QuotParts"%>
<%@page import="com.crm.entity.Supplier"%>
<% Business bus=(Business)session.getAttribute("business");%>
<%
String address=null;
if(request.getAttribute("address")!=null){
	address=request.getAttribute("address").toString();
}
%>
<script language="JavaScript">
  function setunitprice(rno) {
	
	 /* alert("Todays INR IS:"+todays_INR); */
	 
	  var qty =document.getElementById('qtyid'+rno).value;
	 /*  alert("Qty Is:"+qty); */
	  
	  var  unitval=document.getElementById('upriceid'+rno).value;
	  /* alert("Unit Val Is:"+unitval); */
	  
	  var  discount =document.getElementById('discountid'+rno).value;
	  /* alert("Fright Val Is:"+fright); */
	  
	  var aprice=(unitval);
	 /*  alert("Individual Fright Is:"+individual_fright); */
	  
	  var disprice=parseFloat(unitval*(discount/100)).toFixed(2);
	 /*  alert("INR Fright iS:"+INR_Fright); */
	  
	
	  
	  var offerprice=(aprice-disprice).toFixed(2);
	 $("#upricediscid"+rno).attr("value",offerprice);
	 
	  var tot=(offerprice*qty);
	  
	  var disprice=parseFloat(tot).toFixed(2);
	 $("#padisid"+rno).attr("value",disprice);
	 
  }
  </script>

  
  <table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#C5E4EB">
          <tr>
            <td width="30" align="center" valign="middle" background="images/table-box.jpg"  style="background-repeat:repeat-x">S.No </td>
            <td width="111" align="center" valign="middle" background="images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Part number</td>
            <td width="111" align="center" valign="middle" background="images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Description</td>
            <td width="103" align="center" valign="middle" background="images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF"> Qty</td>
            <td width="118" align="center" valign="middle" background="images/table-box.jpg"  style="background-repeat:repeat-x bgcolor="#FFFFFF">Unit Price</td>
            <td width="148" align="center" valign="middle" background="images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Discount(%)</td>
            <td width="118" align="center" valign="middle" background="images/table-box.jpg"  style="background-repeat:repeat-x bgcolor="#FFFFFF">Unit Price After Discount</td>
            <td width="143" align="center" valign="middle" background="images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Price after discount</td>
          </tr>
          
          <%
List<QuotParts> qplist=(List<QuotParts>)request.getAttribute("quotpartslist");
        String  tdate=(String)request.getAttribute("curdate");
System.out.println("Jsp Result of partslist  "+request.getAttribute("quotpartslist"));
System.out.println("the list of parts in jsp  "+qplist);
%>
          <% if(qplist.size()>0){
             for(int i=0;i<qplist.size();i++){  
            	 int discprice=(int)((qplist.get(i).getQty())*(qplist.get(i).getUtprice()));
             %>
            
          <tr>
            <td align="center" bgcolor="#FFFFFF"> 
            <input type="hidden" value="<%=qplist.size() %>" name="rowcount" id="rowcountid"/>
            <input name="sno<%=i %>" value="<%=i+1 %>" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="partid<%=i %>" id="partid<%=i %>"  value="<%=qplist.get(i).getPartid().getPartid()%>" type="hidden" size="5" /><input name="partno<%=i %>" id="partno<%=i %>"  value="<%=qplist.get(i).getPartid().getPrtnum()%>" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="desc<%=i %>" id="desc<%=i %>"  value="<%=qplist.get(i).getPartid().getDescription()%>" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="qty<%=i %>" id="qtyid<%=i %>" value="<%=qplist.get(i).getQty() %>" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="uprice<%=i %>" id="upriceid<%=i %>" value="<%=qplist.get(i).getUtprice() %>" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="discount<%=i %>"  id="discountid<%=i %>" onblur="javascript :setunitprice(<%=i %>) ;" value="0" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="upricedisc<%=i %>" id="upricediscid<%=i %>" value="<%=qplist.get(i).getUtprice() %>" type="text" size="5" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="padiscount<%=i %>" id="padisid<%=i %>"  value="<%=discprice %>" type="text" size="5" /></td>
          </tr>
     <%}
             }%>
  </table>
  <table width="100%">
<tr><td>&nbsp;</td></tr>
<tr>
  <td align="left" valign="top" width="40%"><table border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td align="left" valign="top">Billing Address:</td>
      <td width="316" align="left" valign="top">Shipping Address:</td>
      <td width="32" align="left" valign="top">&nbsp;</td>
      <td width="461">Terms and Conditions</td>
      <td width="31" align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top"><textarea name="billto" class="form-textarea"><%=address%></textarea></td>
      <td align="center" valign="top"><textarea  name="shipto" class="form-textarea"><%=address%></textarea></td>
      <td align="left" valign="top">&nbsp;</td>
      <td><textarea rows="5" cols="58" name="termsAndConditions"><%=bus.getTandc() %></textarea></td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr><td>&nbsp;</td></tr>
    <tr>
<td align="left" width="" valign="middle">
<table><tr><td  height="100px" align="center" width="110px" valign="top">BankGuarntee:</td>
<td height="60px" align="center" width="110px" valign="top"><input type="checkbox" value="" name="bgcheck" id="bgcheck"/></td></tr></table> </td>
<td colspan="3" align="left" valign="top" >
<div id="bgdiv" style="display: none;">
<table width="400">
  
  <tr><td width="121">Given Date:</td>
  <td width="267"><input type="text"  value="<%=tdate %>" style="width: 150px" class="form" name="bgdate" id="bgdate"/></td></tr>
<tr><td>End Date:</td><td><input type="text" value="" style="width: 150px" class="form" name="bgedate" id="bgedate"/></td></tr>
<tr>
  <td>Bank Copy:</td>
  <td><div class="upload" id="bcdiv" onclick="getbankFile()">Click to upload a file</div>
						<div style='height: 0px;width: 0px; overflow:hidden;'>
                      <input id="bankfile" type="file" name="bankcopy" value="upload" onchange="sub1(this)"/>
                    </div></td>
</tr>
</table>
</div></td>
    </tr>
<tr>
<td align="left" width="" valign="middle">
<table><tr><td align="center"  height="100px"  width="110px" valign="top">Warranty:&nbsp;</td>
<td height="60px" align="center" width="110px" valign="top"> <input type="checkbox" value="" name="warcheck" id="warcheck"/></td></tr></table></td>
<td colspan="3" align="left" valign="top">
<div id="wardiv" style="display: none;">
<table width="400"><tr><td width="121">Given Date:</td>
<td><input type="text" value="<%=tdate %>" style="width: 150px"  class="form" name="wargdate" id="wargdate"/></td></tr>
<tr><td>End Date:</td><td><input type="text" value=""  class="form"  style="width: 150px" name="waredate" id="waredate"/></td></tr>
<tr>
  <td>Warranty Copy:</td>
  <td> <div class="upload"  id="wcdiv" onclick="getwarFile()">Click to upload a file</div>
						<div style='height: 0px;width: 0px; overflow:hidden;'>
                      <input id="warfile" type="file" name="warcopy" value="upload" onchange="sub2(this)"/>
                    </div> </td>
</tr>
</table>
</div>
</td>
<td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
<tr>
  <td align="left" valign="middle">&nbsp;</td>
  <td colspan="3" align="right" valign="top"><input name="hidden" type="hidden" id="tc" value="0"/>
    <input name="submit" type="submit" class="button"  onclick="javascript: return validateForm()" value="Generate PI"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  <td align="left" valign="top">&nbsp;</td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
    
<tr><td align="center"></td></tr>

</table>
</td></tr></table>
    
	  <script type="text/javascript">
      $("#bgcheck").click(function(){
    	  $("#bgdiv").toggle();
      });
      $("#warcheck").click(function(){
    	  $("#wardiv").toggle();
      });
      $("#historyDiv").click(function(){
    	  $("#tableId").toggle();
      });
      
      </script>
      <script>
      $(function(){
			 var client="<%=request.getAttribute("clientdet")%>";
			 var cldiv="<%=request.getAttribute("division")%>";
			 var cluser="<%=request.getAttribute("user")%>";
			 $("#enqclient").html("Client Name Is:<span class='cliendet'>"+client +
			"</span>   &nbsp;&nbsp;&nbsp;&nbsp;  Client Division Is:<span class='cliendet'>"+cldiv+
			 "</span>    &nbsp;&nbsp;&nbsp;&nbsp;    Client User Is:<span class='cliendet'>"+cluser+"</span>");
			 $("#enqclient").show();
		});
	$(function() {
		$( "#bgdate" ).datepicker({minDate:0, dateFormat: "dd-mm-yy" },"option", "autoSize", true);
	});
	$(function() {
		$( "#bgedate" ).datepicker({minDate:0, dateFormat: "dd-mm-yy" },"option", "autoSize", true);
	});
	$(function() {
		$( "#wargdate" ).datepicker({ minDate:0,dateFormat: "dd-mm-yy" },"option", "autoSize", true);
	});
	$(function() {
		$( "#waredate" ).datepicker({ minDate:0,dateFormat: "dd-mm-yy" },"option", "autoSize", true);
	});
	</script>